﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using TFXK.Model;
using TFXK.BLL;
using TFXK.Common;
using log4net;

public partial class admin_MsgManage_Action : BasePage
{
    private static readonly ILog log = LogManager.GetLogger(typeof(admin_MsgManage_Action));
    private static readonly MessageBLL bll = new MessageBLL();

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int id = int.Parse(Request.QueryString["id"].ToString());
                    InitData(id);
                }
                else
                {
                    Response.Redirect("Default.aspx", false);
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }

    }
    #endregion

    #region 绑定
    private void InitData(int id)
    {
       TFXK.Model.Message model = bll.GetModel(id);
        if (model != null)
        {
            hiddenid.Value = id + "";
            this.lblTitle.Text = model.title;
            this.lblUserName.Text = model.name;
           // lblSex.Text = model.userId.Value == 0 ? "男" : "女";
            lblCreateDate.Text = model.createTime;
            lblDes.Text = model.description;
            lblEmail.Text = model.email;
            lblTelephone.Text = model.telephone;
            hiddenTypeid.Value = model.parentId + "";
            txtRe.Text = model.reply;

        }

        
    }
    #endregion
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            bll.Delete(int.Parse(Request.QueryString["id"]));
            Msg.ShowAndRedirect("删除成功！", "default.aspx");
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            TFXK.Model.Message model = bll.GetModel(id);
            model.state = "1";
            model.reply = txtRe.Text;
            bll.Update(model);
            Msg.ShowAndRedirect("回复成功！", "Default.aspx");
        }
        catch { }
    }
}
